package com.ytjj.qmyx.admin.dao;

import com.ytjj.qmyx.admin.model.dto.SonOrderDto;
import com.ytjj.qmyx.admin.model.request.*;
import com.ytjj.qmyx.admin.model.request.exportInterface.NotifyOrderInfoRequest;
import com.ytjj.qmyx.admin.model.response.OrderPayInfoResponse;
import com.ytjj.qmyx.admin.model.response.OrdersExportResponse;
import com.ytjj.qmyx.admin.model.response.OrdersInfoResponse;
import com.ytjj.qmyx.admin.model.response.TwoOrdersResponse;
import com.ytjj.qmyx.admin.model.response.order.OrderInfoResponse;
import com.ytjj.qmyx.admin.model.response.order.OrderStatusResponse;
import com.ytjj.qmyx.admin.model.vo.SonOrderVO;
import com.ytjj.qmyx.mall.model.*;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 订单dao
 *
 *
 * @version 1.0
 *
 */
public interface OrdersDao {

    /**
     * 查询主订单列表
     *
     * @param request
     * @return
     */
    List<Orders> queryOrdersList(OrdersRequest request);

    /**
     * 查询订单明细列表
     *
     * @param request
     * @return
     */
    List<OrdersInfoResponse> queryOrdersInfoList(OrdersInfoRequest request);

    /**
     * 查询订单信息
     *
     * @param id
     * @return
     */
    OrdersInfoResponse queryOrdersInfoById(@Param("id") Integer id);

    /**
     * 查询支付订单信息
     *
     * @param resOrderNo
     * @return
     */
    OrdersPay queryOrdersPayByResOrderNo(@Param("resOrderNo") String resOrderNo);

    /**
     * 查询支付订单信息
     */
    List<OrdersPay> queryOrdersPays(@Param("list") List<String> resOrderNos);


    int updateOrderCheack(List<Integer> orderInfoIds);

    /**
     * 今日订单总数
     * @return
     */
    List<Orders> selTodayOrderCount();

    /**
     * 今日销售总额
     * @return
     */
    BigDecimal selTodaySaleCount();

    /**
     * 今日销售商品成本
     * @return
     */
    BigDecimal getCostPriceToDay();

    /**
     * 根据订单状态获取订单数
     * @param orderStatus
     * @return
     */
    Integer getOrdersByStatus(Integer orderStatus);

    /**
     * 根据平台渠道获取今日已下单数
     * @param orderSource
     * @return
     */
    Integer getPayCountBySource(String orderSource);

    /**
     * 根据平台渠道获取昨日已下单数
     * @param orderSource
     * @return
     */
    Integer getYestPayCountBySource(String orderSource);

    /**
     * 获取所有订单列表
     * @return
     */
    List<Orders> getAllOrder();

    /**
     * 根据订单id获取订单详情列表
     * @param orderId
     * @return
     */
    List<OrdersInfo> getAllOrdersInfoByOrderId(Integer orderId);

    /**
     * 根据订单id修改订单状态
     * @param orderId
     * @return
     */
    Integer updateStatusByOrderId(@Param("ordersinfoStatus") String ordersinfoStatus,
                                  @Param("orderId") Integer orderId);

    Integer updateStatusByOid(@Param("id") Integer id, @Param("ordersinfoStatus") String ordersinfoStatus, @Param("closeRemarks") String closeRemarks);

    Orders getProductIdByOrderNo(String orderNo);

    String getExpressNo(Integer id);

    List<OrdersInfo> getOrderInfoList(@Param("orderId") Integer orderId);

    List<OrdersInfo> selectOrderInfoList(@Param("orderId") Integer orderId, @Param("childOrderNo") String childOrderNo, @Param("orderInfoId") Integer orderInfoId);

    Date getDeliveryTime(@Param("expressCompanyNo") String expressCompanyNo, @Param("expressNo") String expressNo);

    void updateOrderInfo(OrderAddressRequest orderAddressRequest);

    void updateOrders(OrderAddressRequest orderAddressRequest);

    List<ExpressDic> getExpressDicList();

    List<Integer> getOrderInfoId(@Param("orderId") Integer orderId);

    List<String> getTelList();

    List<TwoOrdersResponse> queryTwoOrdersList(OrdersRequest request);

    void updateOrderExpress(TwoOrderRequest twoOrderRequest);

    void updateOrderStatus(@Param("id") Integer id);

    boolean fillOrderExpress(@Param("orderId") Integer orderId, @Param("expressCompanyNo") String expressCompanyNo, @Param("expressNo") String expressNo,@Param("orderInfoId") Integer orderInfoId);

    boolean insertExpress(@Param("expressCompanyNo") String expressCompanyNo, @Param("expressNo") String expressNo,@Param("childOrderNo") String childOrderNo);

    boolean fillOrder(@Param("expressCompanyNo") String expressCompanyNo, @Param("expressNo") String expressNo,@Param("express")String express,@Param("orderInfoId") Integer orderInfoId);

    Integer getValidOrders(@Param("orderId") Integer orderId);

    Integer getOrderId(@Param("orderInfoId") Integer orderInfoId);

    BigDecimal getSpecCostPrice(@Param("productId") Integer productId, @Param("skuSpec") String skuSpec);

    BigDecimal getProductCostPrice(Integer productId);

    BankerOrder selectByordersInfoId(@Param("ids") List<String> ids);

    List<BankerOrder> selectByordersInfoIds(@Param("ids") List<String> ids);

    Integer updateOrdersInfoExpress(@Param("list") List<OrdersInfoResponse> list);

    int updateExpress(@Param("ordersInfoResponse") OrdersInfoResponse ordersInfoResponse);

    /**
     * 获取订单明细列表缩减版
     */
    List<OrdersInfoResponse> queryOrdersInfoListCurtail(OrdersInfoRequest request);

    /**
     * 获取订单列表缩减版
     */
    List<Orders> queryOrdersListCurtail(OrdersRequest request);

    Integer selectByOrdersId(Integer orderId);

    void updateExport(String orderNo);

    int updateImport(String orderNo, String expressCompanyNo, String expressNo);

    List<OrdersInfo> selectAllByOrderNo(String orderNo);

    List<OrdersInfo> selectAllByOrderNoList(List list);

    void updateBankerOrders(@Param("list") List<NewImportOrderRequest> list);

    Integer updateSmallNote(@Param("orderNo") String orderNo,@Param("smallNote") String smallNote);

    Orders selectByOrderNo(String orderNo);

    List<SonOrderVO> selectOrderInfoAll(SonOrderDto sonOrderDto);

    OrdersInfo selectByChildOrderNo(Integer orderInfoId);

    OrderStatusResponse returnOrderStatus(Integer id);

    OrderNote findOrderRemark(Integer orderInfoId);

    List<OrdersExportResponse> findAllOrderInfo(OrdersInfoRequest ordersInfoRequest);

    Integer findAllOrderInfoCount(OrdersInfoRequest ordersInfoRequest);

    boolean updateOrderStatusByOrderNo(@Param("orderNo") String orderNo);

    boolean updateServiceRemark(OrdersInfo ordersInfo);

    boolean updateExpressById(@Param("expressCompanyNo") String expressCompanyNo,
                              @Param("expressNo") String expressNo,
                              @Param("orderInfoId") String orderInfoId);

//    boolean updateExpressById(List<NewImportOrderRequest> list);

//    boolean updateOrderStatusByOrderNo(List<NewImportOrderRequest> list);

    int batchUpdateChildOrderStatus(NotifyOrderInfoRequest request);

    List<Orders> findOrderIdsByChild(NotifyOrderInfoRequest request);

    List<OrdersInfoFreightDto> selectFreightByChildOrderNoList(@Param("list") List<String> childOrderNoList);

    List<OrdersPay> getWxAppOrdersPayList(String dateStr);

    List<OrdersPay> getAliPayAppOrdersPayList(String dateStr);

    int updateExpressByChildOrderNo(@Param("childOrderNo") String childOrderNo,
                                        @Param("expressCompanyNo") String expressCompanyNo,
                                        @Param("expressNo") String expressNo);
    /**
     * 查询用户最新下单的一个数据的token
     */
    List<Orders> queryTokenByTel(@Param("telList") List<String> telList);


    List<OrdersPay> getRepeatOrderPayList(String orderNo);

    int updateOrderPayStatus(Integer id);

    /**
     * 根据商品id获取未发货的子订单数
     */
    List<OrdersInfo> getUnDeliveryByProductId(Integer productId);

    /**
     * 获取支付配置
     */
    PayConfig getPayConfigByCompany(@Param("company") String company, @Param("type") String type,
                                    @Param("tradeType") String tradeType);

    /**
     * 根据支付单号获取订单信息
     */
    List<OrderPayInfoResponse> getPayInfoByPayNo(@Param("resOrderNos") List<String> resOrderNos);

    /**
     * 根据服务单号获取订单信息
     */
    List<OrderPayInfoResponse> getPayInfoByServiceNos(@Param("serviceNos") List<String> serviceNos);

    /**
     * 根据子订单id获取主订单信息
     * @param orderInfoId
     * @return
     */
    Orders getOrdersByOrderInfoId(@Param("orderInfoId") Integer orderInfoId);

    /**
     * 根据子订单号获取订单商品信息
     */
    List<OrderInfoResponse> queryByChildOrderNos(@Param("childOrderNos") List<String> childOrderNos);
}
